﻿using System.Data;
using System.Data.OracleClient;
using System.Windows.Data;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class VICC_EXART
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {
            #region
            #endregion
            switch (app.company)
            {

                default:
                    #region
                    dwReturn["ID"] = "1";
                    dwReturn["ARTICLE"] = "                        ";
                    dwReturn["DESCRIPTION"] = "                              ";
                    dwReturn["TWIDTH"] = "";
                    dwReturn["VWIDTH"] = "";
                    dwReturn["GSQM"] = "";
                    dwReturn["GM"] = "";
                    dwReturn["YARN"] = "";
                    dwReturn["PRICE"] = "";
                    dwReturn["SPRICE"] = "";
                    dwReturn["COMPOSITION"] = "                                                                        ";
                    dwReturn["CUSTOMERPRICE"] = "                        ";
                    dwReturn["BOOK"] = "                        ";
                    dwReturn["LOCATION"] = "                        ";
                    dwReturn["CODE"] = "                        ";
                    dwReturn["WIDTH"] = "                    ";
                    dwReturn["WEIGHT"] = "                    ";
                    dwReturn["SUPPLIER"] = "        ";
                    dwReturn["REMARK"] = "";

                    #endregion
                    break;
            }
        }

        public void InserICC_EXART(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            or1 = OracleDB.CreateCommand();
            switch (app.company)
            {

                case "YGR":
                case "SXN":
                case "TST":
                case "UBT":
                default:
                    or1.CommandText = "DELETE FROM ICC_EXART WHERE DESCRIPTION=:DESCRIPTION:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    Connect2Proxy(or1); 
                    or1.CommandText = "INSERT INTO ICC_EXART ( ARTICLE,DESCRIPTION,COMPOSITION,WEIGHT,WIDTH,CODE,LOCATION,BOOK,CUSTOMERPRICE,SUPPLIER,REMARK)"
                    + " VALUES (:ARTICLE:,:DESCRIPTION:,:COMPOSITION:,:WEIGHT:,:WIDTH:,:CODE:,:LOCATION:,:BOOK:,:CUSTOMERPRICE:,:SUPPLIER:,:REMARK:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
            }
            Connect2Proxy(or1);
        }
        public void UpdateICC_EXART(DataRow dwData, int option = 1)
        {
            if (option == 0)
            {
                switch (app.company)
                {
                    case "YGR":
                    default:
                        option = 1;
                        break;
                }
            }
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1: UAM01(dwData); break;
                default:
                    break;
            }
        }
        public void UAM01(DataRow dwData)
        {
            dwData["REMARK"] = dwData["REMARK"].ToString().Replace("'", "''");
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE ICC_EXART SET ID =:ID:,ARTICLE =:ARTICLE:,DESCRIPTION =:DESCRIPTION:,TWIDTH =:TWIDTH:,VWIDTH =:VWIDTH:,GSQM =:GSQM:,GM =:GM:,YARN =:YARN:,PRICE =:PRICE:,SPRICE =:SPRICE:,COMPOSITION =:COMPOSITION:,CUSTOMERPRICE =:CUSTOMERPRICE:,BOOK =:BOOK:,LOCATION =:LOCATION:,CODE =:CODE:,WIDTH =:WIDTH:,WEIGHT =:WEIGHT:,SUPPLIER =:SUPPLIER:,REMARK =:REMARK:"
                           + " WHERE ARTICLE=:ARTICLE:   ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData); 
            Connect2Proxy(or1);

        }

        public DataSet QEXART00(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM ICC_EXART WHERE  ROWNUM<2 ";
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QEXART01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM ICC_EXART M "
            + " WHERE ARTICLE=:ARTICLE:   ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }


        public void DAM00(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM ICC_EXART "
                 + " WHERE AMMANDANT=:AMMANDANT:  ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);

        }
        public void DAM01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM ICC_EXART WHERE "
                 +dwData["ARTICLE"].ToString();
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);

        }

    }
}
